<template>
  <a-modal
    :visible="visible"
    title="问题导入"
    cancelText="取消"
    okText="确定"
    @ok="cancel"
    @cancel="cancel"
  >
    <div style="color: red; line-height: 28px; margin-top: -20px;">
      <a-icon type="link" />
      上传说明:<br />
      1、附件上传小于100MB!<br />
      2、仅允许导入“.xlsx, .xls”格式文件！<br />
    </div>
    <a-upload
      :action="actionUrl"
      list-type="text"
      :headers="headers"
      accept="application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    >
      <a-button>
        <upload-outlined></upload-outlined>
        upload
      </a-button>
    </a-upload>
  </a-modal>
</template>
<script>
import request from "@/api/request"
import { defineComponent, reactive, ref, watch } from "vue";
import { message } from 'ant-design-vue';

var typeKey = 1;

export default defineComponent({
  props: {
    visible: {
      type: Boolean,
    },
    record: {
      type: Object,
    }
  },
  emit: ["close"],
  setup(props, context) {
    const formRef = ref();

    const formState = reactive({});

    const formRules = {};

    const fileList = ref([]);
    const uploading = ref(false);

    const cancel = (e) => {
      context.emit("close", false);
    };

    const tokenKey = localStorage.getItem("token_key");
    const token = localStorage.getItem("token")

    const headers = {
        "Authorization": token,
        "Authorization-key": tokenKey
    };

    watch(props,(props)=>{
      typeKey = props.record.type;
    });

    ///加载上传地址
    //actionUrl();

    const actionUrl = () => {
      return "http://localhost:9292/api/project/cjwt/importCommonProblemExcel?type="+ typeKey;
    }

    return {
      cancel,
      headers,
      formRef,
      formState,
      formRules,

      actionUrl,

      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
    };
  },
});
</script>
